#include <mpi.h>
#include "methods.hh"
#include "../utils/tools.hh"
#include "../utils/constant.hh"

void icehpc::init(hexagon const& hex, solver & s)
{
    auto  start = s.start;
    auto  end   = s.end;
    auto& b     = s.b;
    auto  h     = hex.delta;
    auto  c     = hex.c;

    for (auto id = start, i = 0; id <= end; id++, i++) {
        if (id == hex.except_id) continue;
        if (hex.top(id) || hex.bottom(id)) {
            b[i] = 3 * hex.value(id) * h * h + 2 * constant::r3 * c * h;
            continue;
        }
        if (hex.boundary(id)) {
            b[i] = 3 * hex.value(id) * h * h + 4 * constant::r3 * c * h;
            continue;
        }
        if (hex.inside(id)) {
            b[i] = 3 * hex.value(id) * h * h;
            continue;
        }
    }
}

